﻿
var Url = "AjaxData/CustomOperating.aspx";
//自动以双击方法
function CustomDbClick() {
    window.parent.$("#tabs").tabs('close', '查看客户信息');
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData("CustomerID");
    vname = record.getData("CustomerName");
    var pagetitle = "查看客户信息";
    parent.addTabs(pagetitle, '../Crm/Customer/AddCustomer.aspx?r=' + Math.random() + '&flag=&entity=CrmCustomer&id=' + vid + '&title=' + encodeURI(pagetitle));
    parent.NeedRefreshPage = this;
}
//自定义新增方法
var fnCustomAdd = function () {

}
//自定义修改方法
var fnCustomEdit = function () {

}
//自定义删除方法
var fnCustomDeleteData = function () {
    YAHOO.example.container.dialog3.hide();
}
//转向私海
var fnRemovePrivate = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    var cid = record.getData("CustomerID");
    if (confirm("是否确定把该客户转向私海?")) {
        var SaveUrl = Url + "?r=" + Math.random() + "&action=procedure&entity=CrmCustomerReadyToPrivate&json=&id=" + vid + "&cid=" + cid;
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        alert("客户转向私海成功!");
                        //RefreshData();
                    }
                    else {
                        alert(str);
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
}
//转向公海
var fnRemovePublic = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    var cid = record.getData("CustomerID");
    if (confirm("是否确定把该客户转向公海?")) {
        var SaveUrl = Url + "?r=" + Math.random() + "&action=procedure&entity=CrmCustomerReadyToPublic&json=&id=" + vid + "&cid=" + cid;
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        alert("客户转向公海成功!");
                        //RefreshData();
                    }
                    else {
                        alert(str);
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
}